package com.tsmti.system.entity;

import com.tsmti.core.common.entity.AbstractEntity;
import com.tsmti.core.common.entity.BaseDataEntity;
import com.tsmti.core.common.entity.BaseEntity;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;

/**
 * @Package：com.tsmti.system.entity
 * @Class：UserRole
 * @Description： 用户-角色
 * @Author：zcw
 * @Date：Created in 2018/1/30 18:12
 * @Company:
 * @Version：
 * @Modified By:
 */
@Entity
@Table(name = "pims_user_role", schema = "")
@DynamicUpdate
@DynamicInsert
@SuppressWarnings("serial")
public class UserRole extends AbstractEntity<Long> {

    /** 编号 */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_USERROLE")
    @SequenceGenerator(name = "SEQ_USERROLE", sequenceName = "userrole_sequence", allocationSize = 1)
    private Long id;

    /** 用户编号 */
    private Long userId;

    @ManyToOne
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "userId", nullable = false, updatable = false, insertable = false)
    private User user;

    /** 角色编号 */
    private Long roleId;

    @ManyToOne
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "roleId", nullable = false, updatable = false, insertable = false)
    private Role role;

    /**
     * 获取 id
     *
     * @return: String 编号
     */
    @Override
    public Long getId() {
        return this.id;
    }

    /**
     * 设置 id
     * @param: id 编号
     */
    @Override
    public void setId(Long id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }


    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }


    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

}
